import Vue from 'vue'
import VueRouter from 'vue-router'
import login from '../views/Login'
import recommed from '../views/Recommed'
import center from '../views/Center'
import hot from '../views/Hot'
import chart from '../views/Chart'
import album from '../views/Album'
import local from '../views/Local'
import download from '../views/Download'
import playInfo from '../views/PlayInfo'
import detail from '../views/Detail'
import search from '../views/Search'

Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    component: login
  },
  {
    path: '/',
    redirect: '/center/local'
  },
  {
    path: '/recommend',
    component: recommed,
    children: [
      {
        path: 'hot',
        component: hot,
        meta:{
          keepAlive: true
        }
      },
      {
        path: 'chart',
        component: chart
      },
      {
        path: 'album',
        component: album
      }, 
      {
        path: 'detail/:id',
        component: detail,
        props: true
      }
    ],
    redirect: '/recommend/hot'
  },
  {
    path: '/center',
    component: center,
    children: [
      {
        path: 'local',
        component: local
      }
    ],
    redirect: '/center/local'
  },
  {
    path: '/download',
    component: download
  },
  {
    path: '/playInfo/:id',
    component: playInfo,
    props: true
  },
  {
    path: '/search/:words',
    component: search,
    props: true,
    meta:{
      keepAlive: true
    }
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
